package gre.english.vocab;

import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.app.ListActivity;
import android.content.Intent;

public class WordList_Activity extends ListActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setListAdapter(new ArrayAdapter<String>(WordList_Activity.this, android.R.layout.simple_list_item_1, VocabDBHelper.WORDS));
	}
	

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		
		// Trying to find the word clicked and passing it to the next page
		Bundle basket  = new Bundle();
		String word = VocabDBHelper.WORDS.get(position);		
		basket.putString("key", word);
		
		// Opening the word activity to show the word with its meaning
		Intent openWord = new Intent(WordList_Activity.this, Word_Activity.class);
		openWord.putExtras(basket);
		// Intent openWord = new Intent("com.gre.english.vocab.WORD");
		startActivity(openWord);
	}
}
